﻿/*文件注释
 * ===============================================================================
 * 说明：
 * 作者：曾永佑
 * 版本：V1.0
 * 创建日期：2013-03-03
 * 完成日期： 
 * 修改纪录：  
 * ===============================================================================
 */  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SRF.Components.Security
{
    public class MyRoleProvider : System.Web.Security.RoleProvider
    { 
        readonly Data.DBHelperBase dbhelper = Data.DBHelperFactory.GetDBHelper();

        public override string[] GetRolesForUser(string username)
        {
            //return new string[] { "IT管理员" };
            return dbhelper.GetQuery(Constants.GetRoleListSQL).SetParameter("loginid", username).List<string>().ToArray<string>();
        }

        public override string[] GetAllRoles()
        {
            return dbhelper.GetQuery(Constants.GetRoleListSQL).List<string>().ToArray<string>();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            return dbhelper.GetQuery(Constants.GetUserListSQL).SetParameter("role", roleName).List<string>().ToArray<string>();
        }

        #region 未实现

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }


        public override bool IsUserInRole(string username, string roleName)
        {
            throw new NotImplementedException();
        }

        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}